package com.adopapa.ethexplorer.domain;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonFormat;

@Entity
@Table(name = "BLOCK_INFO")
public class BlockInfo extends BaseUuidEntity {

	private static final long serialVersionUID = -3406224654108768492L;

	@Column(name = "block_number")
	private Long number;
	@Column(name = "hash")
	private String hash;
	@Column(name = "nonce", scale = 24, precision = 0)
	private Long nonce;
	@Column(name = "time_stamp")
	private Long timestamp;
	@Column(name = "tx_count")
	private Long txCount;
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
	@Column(name = "create_time")
	private Instant createTime;

	public Long getNumber() {
		return number;
	}

	public void setNumber(Long number) {
		this.number = number;
	}

	public BlockInfo number(Long number) {
		this.number = number;
		return this;
	}

	public String getHash() {
		return hash;
	}

	public void setHash(String hash) {
		this.hash = hash;
	}

	public BlockInfo hash(String hash) {
		this.hash = hash;
		return this;
	}

	public Long getNonce() {
		return nonce;
	}

	public void setNonce(Long nonce) {
		this.nonce = nonce;
	}

	public BlockInfo nonce(Long nonce) {
		this.nonce = nonce;
		return this;
	}

	public Long getTimestampRaw() {
		return timestamp;
	}

	public void setTimestamp(Long timestamp) {
		this.timestamp = timestamp;
	}

	public BlockInfo timestamp(Long timestamp) {
		this.timestamp = timestamp;
		return this;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
	public LocalDateTime getTimestamp() {
		return LocalDateTime.ofEpochSecond(this.timestamp, 0, ZoneOffset.ofHours(8));
	}

	public Long getTxCount() {
		return txCount;
	}

	public void setTxCount(Long txCount) {
		this.txCount = txCount;
	}

	public BlockInfo txCount(Long txCount) {
		this.txCount = txCount;
		return this;
	}

	public Instant getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Instant createTime) {
		this.createTime = createTime;
	}
	
	
	public BlockInfo createTime(Instant createTime) {
		this.createTime = createTime;
		return this;
	}
	
	

}
